package case1

import (
	"fmt"
	"log"
)
import (
	"github.com/jinzhu/gorm"
	_ "github.com/jinzhu/gorm/dialects/mysql" // 连接mysql驱动
)

// "github.com/jinzhu/gorm" 这个是gorm 版本1！！！

//Github GORM
//gorm是一个使用Go语言编写的ORM框架。它文档齐全，对开发者友好，支持主流数据库。
//安装： go get -u github.com/jinzhu/gorm
//依赖：
//import _ "github.com/jinzhu/gorm/dialects/mysql"
// import _ "github.com/jinzhu/gorm/dialects/postgres"
// import _ "github.com/jinzhu/gorm/dialects/sqlite"
// import _ "github.com/jinzhu/gorm/dialects/mssql"

func Test() {
	fmt.Println("🎯示例一：连接Mysql")

	db, err := gorm.Open("mysql", "root:123456@(127.0.0.1:3306)/case1?charset=utf8mb4&parseTime=True&loc=Local")
	if err != nil {
		panic("failed to connect database")
	}
	defer db.Close()

	log.Println("Connected to MySQL database successfully!")
}
